#!/usr/bin/perl

use CGI qw(:standard);
use strict;
use warnings;

my $fils = param('f');
my $cols = param('c');

print header(-type => 'application/json');

if ($fils > 0 && $cols > 0 && $fils < 10 && $cols < 10) {
  print "\{ \"tabla\": \{\n";

  for (my $i = 0; $i < $fils; $i++) {
    print "    \"fila_$i\": \{\n";
    for (my $j= 0; $j < $cols; $j++) {
      if ($j == $cols - 1) {
        print "      \"columna_$j\": \"[$i,$j]\"\n";
      } else {
        print "      \"columna_$j\": \"[$i,$j]\",\n";
      }
    }
    if ($i == $fils - 1) {
      print "    \}\n";
    } else {
      print "    \},\n";
    }
  }

  print  "  \}\n\}";
} else {
  print "\{ \"tabla_vacia\": \"tabla_vacia\" \}";
}
